﻿using EventHandlerDemo.Domain.Orders;
using EventHandlerDemo.Infrastructure.EFCore;
using Microsoft.EntityFrameworkCore;

namespace EventHandlerDemo.Infrastructure.Repositories.Orders
{
    public class OrderRepository : RepositoryBase, IOrderRepository
    {
        public OrderRepository(AppDbContext dbContext) : base(dbContext)
        {

        }

        public async Task<Order?> FirstOrDefaultAsync(int id)
        {
            var order = await _dbContext.Set<Order>().FirstOrDefaultAsync(o => o.Id == id);
            return order;
        }

        public async Task InsertAsync(Order order)
        {
            await _dbContext.AddAsync(order);
        }
    }
}
